﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace YouJiBiaoDing
{
    public partial class Form3 : Form
    {
        public ArrayList AddrList;
        int TargetAddr;
        public Form3(ArrayList al,int _TargetAddr)
        {
            InitializeComponent();
            AddrList = new ArrayList();
            AddrList.Clear();
            TargetAddr = _TargetAddr;
            for (int i = 0; i < al.Count; i++)
            {
                AddrList.Add(al[i]);
                checkedListBox1.Items.Add(al[i], true);
            }
            bool bRepeat;
            for (int i = 1; i < 256; i++)
            {
                if (TargetAddr == i)
                    continue;
                bRepeat=false;
                for (int j = 0; j < al.Count; j++)
                {
                    if (i == Convert.ToInt32(al[j]))
                    {
                        bRepeat = true;
                        break;
                    }
                }
                if (bRepeat)
                    continue;
                toolStripComboBox1.Items.Add(i);
            }
            toolStripComboBox1.SelectedIndex = 0;
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            checkedListBox1.Items.Clear();
            toolStripComboBox1.Items.Clear();
            for (int i = 1; i < 256; i++)
            {
                if (TargetAddr == i)
                    continue;                
                toolStripComboBox1.Items.Add(i);
            }
            toolStripComboBox1.SelectedIndex = 0;
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            checkedListBox1.Items.Add(toolStripComboBox1.Text, true);
            toolStripComboBox1.Items.RemoveAt(toolStripComboBox1.SelectedIndex);
            toolStripComboBox1.SelectedIndex = 0;
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            AddrList.Clear();
            for (int i = 0; i < checkedListBox1.CheckedItems.Count; i++)
            {
                AddrList.Add(checkedListBox1.CheckedItems[i]);
            }
            this.Close();
        }
    }
}
